﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Text;

namespace Meqs.Logic.Batcher
{
    /// <summary>
    /// 批处理接口
    /// </summary>
    public interface IBatcher
    {
        /// <summary>
        /// 获得批处理是否正在批处理状态。
        /// </summary>
        bool Started { get; }

        /// <summary>
        /// 开始批处理。
        /// </summary>
        /// <param name="connection">连接。</param>
        /// <param name="type">
        /// Command类型:
        /// INSERT
        /// UPDATE
        /// DELETE
        /// </param>
        void StartBatch(IDbConnection connection, string type);

        /// <summary>
        /// 开始批处理。
        /// </summary>
        /// <param name="connection">连接。</param>
        /// <param name="tran"></param>
        /// <param name="type">
        /// Command类型:
        /// INSERT
        /// UPDATE
        /// DELETE
        /// </param>
        void StartBatch(IDbConnection connection, IDbTransaction tran, string type);

        /// <summary>
        /// 添加批命令。
        /// </summary>
        /// <param name="command">命令</param>
        void AddToBatch(IDbCommand command);

        /// <summary>
        /// 执行批处理。
        /// </summary>
        /// <returns>影响的数据行数。</returns>
        int ExecuteBatch();

        /// <summary>
        /// 结束批处理。
        /// </summary>
        void EndBatch();

        /// <summary>
        /// 清空保存的批命令。
        /// </summary>
        void ClearBatch();
    }
}
